//
//  StatusCell.m
//  weibo
//
//  Created by qiuming on 15/12/26.
//  Copyright © 2015年 qiuming. All rights reserved.
//

#import "StatusCell.h"
#import "StatusOriginalView.h"
#import "StatusToolBar.h"


@interface StatusCell()
/// 原创微博视图
@property (strong, nonatomic) StatusOriginalView *originalView;
/// 底部视图
@property (strong, nonatomic) StatusToolBar *toolBar;
@end

@implementation StatusCell

- (void)setViewModel:(StatusViewModel *)ViewModel {
    _ViewModel = ViewModel;
    
    self.originalView.viewModel = ViewModel;
    self.toolBar.viewModel = ViewModel;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    // 1.添加控件
    [self.contentView addSubview:self.originalView];
    [self.contentView addSubview:self.toolBar];
    // 自动布局
    [self.originalView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top);
        make.left.equalTo(self.contentView.mas_left);
        make.right.equalTo(self.contentView.mas_right);

    }];
    [self.toolBar mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.originalView.mas_bottom);
        make.left.equalTo(self.originalView.mas_left);
        make.right.equalTo(self.originalView.mas_right);
        make.height.mas_equalTo(@44);
        
        // 底部约束
        make.bottom.equalTo(self.contentView.mas_bottom);
    }];
}


#pragma mark - 懒加载
- (StatusOriginalView *)originalView {
    if (_originalView == nil) {
        _originalView = [[StatusOriginalView alloc]init];
    }
    return _originalView;
}

- (StatusToolBar *)toolBar {
    if (_toolBar == nil) {
        _toolBar = [[StatusToolBar alloc]init];
    }
    return _toolBar;
}

@end
